Purchase
A Purchase verifies funds on the customer’s card, removes the funds and prepares them for deposit into the merchant’s account.
package Canada;
import JavaAPI.*;
public class TestCanadaPurchase
{
public static void main(String[] args)
{
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String store_id = "store5";
String api_token = "yesguy";
String amount = "5.00";
String pan = "4242424242424242";
String expdate = "1901"; //YYMM format
String crypt = "7";
boolean status_check = false;
Purchase purchase = new Purchase();
purchase.setOrderId(order_id);
purchase.setAmount(amount);
purchase.setPan(pan);
purchase.setExpdate(expdate);
purchase.setCryptType(crypt);
purchase.setDynamicDescriptor("123456");
//purchase.setWalletIndicator(""); //Refer documentation for possible values
//optional - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("U");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
purchase.setCofInfo(cof);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(purchase);
mpgReq.setStatusCheck(status_check);
//Optional - Proxy
mpgReq.setProxy(false); //true to use proxy
mpgReq.setProxyHost("proxyURL");
mpgReq.setProxyPort("proxyPort");
mpgReq.setProxyUser("proxyUser"); //optional - domainName\User
mpgReq.setProxyPassword("proxyPassword"); //optional
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
System.out.println("HostId = " + receipt.getHostId());
System.out.println("IssuerId = " + receipt.getIssuerId());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase - Transaction Values
Purchase purchase = new Purchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(purchase);
Purchase object mandatory values
Purchase optional values
Purchase With Customer Information
The Customer Information object is an optional add-on to a number of transactions. The Customer Information object offers a number of fields to be submitted as part of the financial transaction, and stored by Moneris. These details may be viewed in the future in the Merchant Resource Center.
In addition to instantiating a transaction object and a connection object (as you would for a normal transaction), you must instantiate a CustInfo object.
Any transaction that supports CustInfo has a setCustInfo method. This is used to write the customer information to the transaction object.
The Customer Information object holds three types of information:
- Miscellaneous customer information properties
- Billing/Shipping information
- Item information
Things to consider:
- If you send characters that are not included in the allowed list, these extra transaction details may not be stored.
- All fields are alphanumeric and allow the following characters: a-z A-Z 0-9 _ - : . @ $ = /
- All French accents should be encoded as HTML entities, such as é
- The data sent in Billing and Shipping Address fields will not be used for any address verification.
package Canada;
import java.util.*;
import JavaAPI.*;
public class TestCanadaPurchaseCustInfo
{
public static void main(String[] args)
{
String store_id = "store5";
String api_token = "yesguy";
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String amount = "10.00";
String pan = "4242424242424242";
String expdate = "1901"; //YYMM format
String crypt = "7";
String processing_country_code = "CA";
boolean status_check = false;
/********************* Billing/Shipping Variables ****************************/
String first_name = "Bob";
String last_name = "Smith";
String company_name = "ProLine Inc.";
String address = "623 Bears Ave";
String city = "Chicago";
String province = "Illinois";
String postal_code = "M1M2M1";
String country = "Canada";
String phone = "777-999-7777";
String fax = "777-999-7778";
String tax1 = "10.00";
String tax2 = "5.78";
String tax3 = "4.56";
String shipping_cost = "10.00";
/********************* Order Line Item Variables *****************************/
String[] item_description = new String[] { "Chicago Bears Helmet", "Soldier Field Poster" };
String[] item_quantity = new String[] { "1", "1" };
String[] item_product_code = new String[] { "CB3450", "SF998S" };
String[] item_extended_amount = new String[] { "150.00", "19.79" };
/*****************************************************************************/
/* */
/* Customer Information Option 1 */
/* */
/*****************************************************************************/
/********************** Customer Information Object **************************/
CustInfo customer = new CustInfo();
/********************** Set Customer Billing Information **********************/
customer.setBilling(first_name, last_name, company_name, address, city,
province, postal_code, country, phone, fax, tax1, tax2,
tax3, shipping_cost);
/******************** Set Customer Shipping Information ***********************/
customer.setShipping(first_name, last_name, company_name, address, city,
province, postal_code, country, phone, fax, tax1, tax2,
tax3, shipping_cost);
/***************************** Order Line Items ******************************/
customer.setItem(item_description[0], item_quantity[0],
item_product_code[0], item_extended_amount[0]);
customer.setItem(item_description[1], item_quantity[1],
item_product_code[1], item_extended_amount[1]);
/*****************************************************************************/
/* */
/* Customer Information Option 2 */
/* */
/*****************************************************************************/
/********************** Customer Information Object **************************/
CustInfo customer2 = new CustInfo();
/******************************* Billing Hashtable ***************************/
Hashtable<String, String> b = new Hashtable<String, String>(); //billing hashtable
b.put("first_name", first_name);
b.put("last_name", last_name);
b.put("company_name", company_name);
b.put("address", address);
b.put("city", city);
b.put("province", province);
b.put("postal_code", postal_code);
b.put("country", country);
b.put("phone", phone);
b.put("fax", fax);
b.put("tax1", tax1); //federal tax
b.put("tax2", tax2); //prov tax
b.put("tax3", tax3); //luxury tax
b.put("shipping_cost", shipping_cost); //shipping cost
customer2.setBilling(b);
/****************************** Shipping Hashtable ***************************/
Hashtable<String, String> s = new Hashtable<String, String>(); //shipping hashtable
s.put("first_name", first_name);
s.put("last_name", last_name);
s.put("company_name", company_name);
s.put("address", address);
s.put("city", city);
s.put("province", province);
s.put("postal_code", postal_code);
s.put("country", country);
s.put("phone", phone);
s.put("fax", fax);
s.put("tax1", tax1); //federal tax
s.put("tax2", tax2); //prov tax
s.put("tax3", tax3); //luxury tax
s.put("shipping_cost", shipping_cost); //shipping cost
customer2.setShipping(s);
/************************* Order Line Item1 Hashtable ************************/
Hashtable<String, String> i1 = new Hashtable<String, String>(); //item hashtable #1
i1.put("name", item_description[0]);
i1.put("quantity", item_quantity[0]);
i1.put("product_code", item_product_code[0]);
i1.put("extended_amount", item_extended_amount[0]);
customer2.setItem(i1);
/************************* Order Line Item2 Hashtable **************************/
Hashtable<String, String> i2 = new Hashtable<String, String>(); //item hashtable #2
i2.put("name", "item2's name");
i2.put("quantity", "7");
i2.put("product_code", "item2's product code");
i2.put("extended_amount", "5.01");
customer2.setItem(i2);
/*************** Miscellaneous Customer Information Methods *******************/
customer.setEmail("nick@widget.com");
customer.setInstructions("Make it fast!");
/********************** Transactional Request Object **************************/
Purchase purchase = new Purchase();
purchase.setOrderId(order_id);
purchase.setAmount(amount);
purchase.setPan(pan);
purchase.setExpdate(expdate);
purchase.setCryptType(crypt);
purchase.setCustInfo(customer);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(purchase);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase - Transaction Values
Purchase purchase = new Purchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(purchase);
Purchase object mandatory values
Purchase optional values
CustInfo object mandatory properties
Setting Billing & Shipping using Set Methods
The billing information and the shipping information for a given CustInfo object are written by using the customer.setBilling() and customer.setShipping() methods respectively:
customer.setBilling(first_name, last_name, company_name, address, city, province, postal_code, country, phone, fax, tax1, tax2, tax3, shipping_cost);
customer.setShipping(first_name, last_name, company_name, address, city, province, postal_code, country, phone, fax, tax1, tax2, tax3, shipping_cost);
Both of these methods have the same set of mandatory arguments.
Setting Billing & Shipping using Hash Tables
Writing billing or shipping information using hash tables is done as follows:
- Instantiate a CustInfo object.
- Instantiate a Hashtable object. (The sample code uses a different hash table for billing and shipping for clarity purposes. However, the skillful developer can re-use the same one.)
- Build the hashtable using put methods with the hash table keys in the table below.
- Call the CustInfo object's setBilling()/setShipping() method to pass the hashtable information to the CustInfo object
- Call the transaction object's setCustInfo() method to write the CustInfo object (with the billing/shipping information to the transaction object.
Billing & Shipping mandatory values
Setting Items using Set Methods
All the item information in the table below is written to the CustInfo object in one instruction for a given item. Multiples items may be set. Such as:
customer.setItem(item_description, item_quantity, item_product_code, item_extended_amount);
Setting Items using Hash Tables
Writing item information using hash tables is done as follows:
- Instantiate a CustInfo object.
- Instantiate a Hashtable object. (The sample code uses a different hash table for each item for clarity purposes. However, the skillful developer can re-use the same one.)
- Build the hashtable using put methods with the hash table keys in the table below.
- Call the CustInfo object's setItem() method to pass the hashtable information to the CustInfo object
- Call the transaction object's setCustInfo() method to write the CustInfo object (with the item information to the transaction object.
Item mandatory values
Purchase with CVD & AVS
The Card Validation Digits (CVD) value refers to the numbers appearing on the back of the credit card rather than the numbers imprinted on the front. It is an optional fraud prevention tool that enables merchants to verify data provided by the cardholder at transaction time. This data is submitted along with the transaction to the issuing bank, which provides a response indicating whether the data is a match.
The response that is received from CVD verification is intended to provide added security and fraud prevention, but the response itself does not affect the completion of a transaction. Upon receiving a response, the choice whether to proceed with a transaction is left entirely to the merchant. The response is not a strict guideline of which transaction will approve or decline.
Address Verification Service (AVS) is an optional fraud-prevention tool offered by issuing banks whereby a cardholder's address is submitted as part of the transaction authorization. The AVS address is then compared to the address kept on file at the issuing bank. AVS checks whether the street number, street name and zip/postal code match. The issuing bank returns an AVS result code indicating whether the data was matched successfully. Regardless of the AVS result code returned, the credit card is authorized or declined by the issuing bank.
The response that is received from AVS verification is intended to provide added security and fraud prevention, but the response itself does not affect the completion of a transaction. Upon receiving a response, the choice to proceed with a transaction is left entirely to the merchant. The responses is not a strict guideline of whether a transaction will be approved or declined.
Things to consider:
- CVD is only supported by Visa, MasterCard, Discover, JCB, American Express and UnionPay.
- AVS is only supported by Visa, MasterCard, Discover and American Express.
- When testing CVD or AVS, you must only use the Visa test card numbers 4242424242424242 or 4005554444444403, and the amounts described in the Simulator eFraud Response Codes Table
- For a full list of possible AVS & CVD result codes refer to the CVD AVS Result Code table
Security:The CVD value must only be passed to the payment gateway. Under no circumstances may it be stored for subsequent uses or displayed as part of the receipt information.
Note:Please be advised that CVD results will NOT be returned in the response for UnionPay.
package Canada;
import JavaAPI.*;
public class TestCanadaPurchaseEfraud
{
public static void main(String[] args)
{
String store_id = "store5";
String api_token = "yesguy";
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String amount = "10.02";
String pan = "4242424242424242";
String expiry_date = "1901"; //YYMM format
String crypt = "7";
boolean status_check = false;
AvsInfo avsCheck = new AvsInfo();
avsCheck.setAvsStreetNumber("212");
avsCheck.setAvsStreetName("Payton Street");
avsCheck.setAvsZipCode("M1M1M1");
avsCheck.setAvsEmail("test@host.com");
avsCheck.setAvsHostname("hostname");
avsCheck.setAvsBrowser("Mozilla");
avsCheck.setAvsShiptoCountry("CAN");
avsCheck.setAvsShipMethod("G");
avsCheck.setAvsMerchProdSku("123456");
avsCheck.setAvsCustIp("192.168.0.1");
avsCheck.setAvsCustPhone("5556667777");
CvdInfo cvdCheck = new CvdInfo();
cvdCheck.setCvdIndicator("1");
cvdCheck.setCvdValue("099");
Purchase purchase = new Purchase();
purchase.setOrderId(order_id);
purchase.setAmount(amount);
purchase.setPan(pan);
purchase.setExpdate(expiry_date);
purchase.setCryptType(crypt);
purchase.setAvsInfo(avsCheck);
purchase.setCvdInfo(cvdCheck);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(purchase);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("Avs Response = " + receipt.getAvsResultCode());
System.out.println("Cvd Response = " + receipt.getCvdResultCode());
System.out.println("ITD Response = " + receipt.getITDResponse());
System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase - Transaction Values
Purchase purchase = new Purchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(purchase);
Purchase object mandatory values
Purchase optional values
CvdInfo object mandatory values
AvsInfo object mandatory values
CVD & AVS Response Fields
Purchase with Credential on File
When storing Customer’s credentials for use in future authorizations, or when using these credentials in subsequent transactions, card brands now require merchants to indicate this in the transaction request.
Things to consider:
- While the requirements for handling credential on file transactions relate to Visa, Mastercard and Discover only, in order to avoid confusion and prevent error, please implement these changes for all card types and the Moneris system will then correctly flow the relevant card data values as appropriate
- When initially storing cardholder credentials, please be sure to adhere to the following:
- Obtain the cardholder’s card verification digits(CVD).
- Issuer ID will be sent without value for the initial transaction.
- The payment information field will always be a value of 0.
- Include cardholder consent prior to cardholder data being stored.
- Financial transaction must be approved before storing.
Note:Credential on file transactions are available to Canada Integrations only.
package Canada;
import JavaAPI.*;
public class TestCanadaPurchase
{
public static void main(String[] args)
{
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String store_id = "store5";
String api_token = "yesguy";
String amount = "5.00";
String pan = "4242424242424242";
String expdate = "1901"; //YYMM format
String crypt = "7";
boolean status_check = false;
Purchase purchase = new Purchase();
purchase.setOrderId(order_id);
purchase.setAmount(amount);
purchase.setPan(pan);
purchase.setExpdate(expdate);
purchase.setCryptType(crypt);
purchase.setDynamicDescriptor("123456");
//purchase.setWalletIndicator(""); //Refer documentation for possible values
//optional - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("U");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
purchase.setCofInfo(cof);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(purchase);
mpgReq.setStatusCheck(status_check);
//Optional - Proxy
mpgReq.setProxy(false); //true to use proxy
mpgReq.setProxyHost("proxyURL");
mpgReq.setProxyPort("proxyPort");
mpgReq.setProxyUser("proxyUser"); //optional - domainName\User
mpgReq.setProxyPassword("proxyPassword"); //optional
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
System.out.println("HostId = " + receipt.getHostId());
System.out.println("IssuerId = " + receipt.getIssuerId());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase - Transaction Values
Purchase purchase = new Purchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(purchase);
Purchase object mandatory values
Purchase optional values
Credential on File Info Object and Variables
The Credential on File Info object is nested within the request for the applicable transaction types.
Object:
Variables in the cof object:
- PaymentIndicator
- PaymentInformation
- IssuerID
For more information, see Definitions of Request Fields – Credential on File and Credential on File Transaction Object Request Fieldsbelow.
Definitions of Request Fields – Credential on File
Purchase with Recurring Billing
Verifies funds on the customer’s card, removes the funds and prepares them for deposit into the merchant’s account.
Recurring Billing allows you to set up payments whereby Moneris automatically processes the transactions and bills customers on your behalf based on the billing cycle information you provide.
In addition to instantiating a transaction object and a connection object (as you would for a normal transaction), you must instantiate a Recur object. This object has a number of mandatory properties that must be set.
Any transaction that supports Recurring Billing has a setRecur method. This is used to write the Recurring Billing information to the transaction object before writing the transaction object to the connection object.
Things to consider:
- To avoid shifting, do not set the start_date after the 28th if the recur_unit is month. To set the billing date for the last day of the month, set recur_unit to eom.
package Canada;
import java.util.*;
import JavaAPI.*;
public class TestCanadaPurchaseRecur
{
public static void main(String[] args)
{
String store_id = "store5";
String api_token = "yesguy";
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String amount = "10.00";
String pan = "4242424242424242";
String expiry_date = "1901"; //YYMM format
String crypt = "7";
/************************* Recur Variables **********************************/
String recur_unit = "month"; //eom = end of month
String start_now = "true";
String start_date = "2018/04/01";
String num_recurs = "12";
String period = "1";
String recur_amount = "30.00";
boolean status_check = false;
/************************* Recur Object Option1 ******************************/
Recur recurring_cycle = new Recur(recur_unit, start_now, start_date,
num_recurs, period, recur_amount);
/************************* Recur Object Option2 ******************************/
Hashtable<String, String> recur_hash = new Hashtable<String, String>();
recur_hash.put("recur_unit", recur_unit);
recur_hash.put("start_now", start_now);
recur_hash.put("start_date", start_date);
recur_hash.put("num_recurs", num_recurs);
recur_hash.put("period", period);
recur_hash.put("recur_amount", recur_amount);
/************************ Transactional Object *******************************/
Purchase purchase = new Purchase();
purchase.setOrderId(order_id);
purchase.setAmount(amount);
purchase.setPan(pan);
purchase.setExpdate(expiry_date);
purchase.setCryptType(crypt);
/******************************* Set Recur ***********************************/
purchase.setRecur(recurring_cycle);
//Mandatory on Recurs - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("R");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
purchase.setCofInfo(cof);
/**************************** Https Post Request ***************************/
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(purchase);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
/******************************* Receipt ***********************************/
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("Recur Success = " + receipt.getRecurSuccess());
System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
System.out.println("IssuerId = " + receipt.getIssuerId());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase - Transaction Values
Purchase purchase = new Purchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(purchase);
Purchase object mandatory values
Purchase optional values
Recurring object mandatory values
Recurring Billing Response Fields
Purchase with Convenience Fee
The Convenience Fee program allows merchants to apply an additional charge to a customer’s bill (with their consent) for the convenience of being able to pay for goods and services using an alternative payment channel. This applies only when providing a true convenience in the form of a channel outside the merchant's customary face-to-face payment channels.
The convenience fee is a charge in addition to what the consumer is paying for the provided goods/services. This charge appears as a separate line item on the consumer’s statement.
The Convenience Fee program provides several benefits. It may allow you an opportunity to reduce or eliminate credit card processing fees and improve customer satisfaction.
In addition to instantiating a transaction object and a connection object (as you would for a normal transaction), you must instantiate a ConvFeeInfo object. This object has one mandatory value that must be set:
package Canada;
import JavaAPI.*;
public class TestCanadaConvFeePurchase
{
public static void main(String args[])
{
String store_id = "monca00392";
String api_token = "qYdISUhHiOdfTr1CLNpN";
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String amount = "10.00";
String pan = "4242424242424242";
String expdate = "1911";
String crypt = "7";
ConvFeeInfo convFeeInfo = new ConvFeeInfo();
convFeeInfo.setConvenienceFee("1.00");
Purchase purchase = new Purchase();
purchase.setOrderId(order_id);
purchase.setAmount(amount);
purchase.setPan(pan);
purchase.setExpdate(expdate);
purchase.setCryptType(crypt);
purchase.setConvFeeInfo(convFeeInfo);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(purchase);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("CfSuccess = " + receipt.getCfSuccess());
System.out.println("CfStatus = " + receipt.getCfStatus());
System.out.println("FeeAmount = " + receipt.getFeeAmount());
System.out.println("FeeRate = " + receipt.getFeeRate());
System.out.println("FeeType = " + receipt.getFeeType());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase - Transaction Values
Purchase purchase = new Purchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(purchase);
Purchase object mandatory values
Purchase optional values
Convenience Fee Mandatory Values
Convenience Fee Response Fields
Purchase with 3-D Secure
The Purchase with 3-D Secure transaction follows a 3-D Secure MPI authentication. After receiving confirmation from the MPI ACS transaction, this Purchase verifies funds on the customer’s card, removes the funds and prepares them for deposit into the merchant’s account.
To perform the 3-D Secure authentication, the Moneris MPI or any 3rd party MPI may be used.
In addition to 3-D Secure transactions, this transaction can also be used to process Apple Pay and Google Pay™ transactions. This transaction is applicable only if choosing to integrate directly to Apple Wallet or Google Wallet (if not using the Moneris Apple Pay or Google Pay™ SDKs).
Refer to Apple or Google developer portals for details on integrating directly to their wallets to retrieve the payload data.
NOTE: Moneris strongly discourages the use of frames as part of a 3-D Secure implementation, and cannot guarantee their reliability when processing transactions in the production environment.
package Canada;
import JavaAPI.*;
public class TestCanadaCavvPurchase
{
public static void main(String[] args)
{
String store_id = "store5";
String api_token = "yesguy";
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String cust_id = "CUS887H67";
String amount = "10.42";
String pan = "4242424242424242";
String expdate = "1901"; //YYMM
String cavv = "AAABBJg0VhI0VniQEjRWAAAAAAA=";
String dynamic_descriptor = "123456";
String crypt_type = "5";
boolean status_check = false;
CavvPurchase cavvPurchase = new CavvPurchase();
cavvPurchase.setOrderId(order_id);
cavvPurchase.setCustId(cust_id);
cavvPurchase.setAmount(amount);
cavvPurchase.setPan(pan);
cavvPurchase.setExpdate(expdate);
cavvPurchase.setCavv(cavv);
cavvPurchase.setCryptType(crypt_type); //Mandatory for AMEX only
cavvPurchase.setDynamicDescriptor(dynamic_descriptor);
//cavvPurchase.setWalletIndicator("APP"); //set only for wallet transactions. e.g APPLE PAY
//cavvPurchase.setNetwork("Interac"); //set only for Interac e-commerce
//cavvPurchase.setDataType("3DSecure"); //set only for Interac e-commerce
//optional - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("U");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
cavvPurchase.setCofInfo(cof);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(cavvPurchase);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("ISO = " + receipt.getISO());
System.out.println("BankTotals = " + receipt.getBankTotals());
System.out.println("Message = " + receipt.getMessage());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("Ticket = " + receipt.getTicket());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("CavvResultCode = " + receipt.getCavvResultCode());
System.out.println("IssuerId = " + receipt.getIssuerId());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase with 3-D Secure - Transaction
CavvPurchase cavvPurchase = new CavvPurchase();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(cavvPurchase);
Purchase object mandatory values
Purchase optional values
3-D Secure Response Fields
Purchase with Vault
This transaction uses the data key to identify a previously registered credit card profile. The details saved within the profile are then submitted to perform a Purchase transaction.
The data key may be a temporary one generated using Hosted Tokenization or it may be a permanent one from the Vault.
The Vault feature allows merchants to create long term customer profiles, edit those profiles, and use them to process transactions without having to enter financial information each time.
The only difference between charging a temporary token and charging a standard Vault token is whether the expiry date is sent. With the Vault token, the expiry date is stored along with the card number as part
of the Vault profile. Therefore, there is no need to send the expiry date again with each normal Vault transaction.
However, a temporary token transaction may have only stored the card number. Therefore, in this scenario the expiry date must be sent when you charge the card.
package Canada;
import JavaAPI.*;
public class TestCanadaResPurchaseCC
{
public static void main(String[] args)
{
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String store_id = "store5";
String api_token = "yesguy";
String data_key = "8OOXGiwxgvfbZngigVFeld9d2";
String amount = "1.00";
String cust_id = "customer1"; //if sent will be submitted, otherwise cust_id from profile will be used
String crypt_type = "1";
String descriptor = "my descriptor";
String expdate = "1512"; //For Temp Token
boolean status_check = false;
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
resPurchaseCC.setData(data_key);
resPurchaseCC.setOrderId(order_id);
resPurchaseCC.setCustId(cust_id);
resPurchaseCC.setAmount(amount);
resPurchaseCC.setCryptType(crypt_type);
//resPurchaseCC.setDynamicDescriptor(descriptor);
//resPurchaseCC.setExpDate(expdate); //Temp Tokens only
//Mandatory - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("U");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
resPurchaseCC.setCofInfo(cof);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(resPurchaseCC);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("DataKey = " + receipt.getDataKey());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Message = " + receipt.getMessage());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("ResSuccess = " + receipt.getResSuccess());
System.out.println("PaymentType = " + receipt.getPaymentType());
System.out.println("IsVisaDebit = " + receipt.getIsVisaDebit());
System.out.println("Cust ID = " + receipt.getResCustId());
System.out.println("Phone = " + receipt.getResPhone());
System.out.println("Email = " + receipt.getResEmail());
System.out.println("Note = " + receipt.getResNote());
System.out.println("Masked Pan = " + receipt.getResMaskedPan());
System.out.println("Exp Date = " + receipt.getResExpdate());
System.out.println("Crypt Type = " + receipt.getResCryptType());
System.out.println("Avs Street Number = " + receipt.getResAvsStreetNumber());
System.out.println("Avs Street Name = " + receipt.getResAvsStreetName());
System.out.println("Avs Zipcode = " + receipt.getResAvsZipcode());
System.out.println("IssuerId = " + receipt.getIssuerId());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase with Vault - Transaction Values
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(resPurchaseCC);
Purchase with Vault mandatory values
Purchase with Vault optional values
Vault Response Fields
Purchase with Vault and Customer Information
The Vault feature allows merchants to create customer profiles, edit those profiles, and use them to process
transactions without having to enter financial information each time.
The Vault is a complement to the recurring payment module. It securely stores customer account information
on Moneris secure servers. This allows merchants to bill customers for routine products or services
when an invoice is due.
An optional add-on to a number of transactions the Customer Information object. The Customer Information
object offers a number of fields to be submitted as part of the financial transaction, and stored by
Moneris. These details may be viewed in the future in the Merchant Resource Center.
package Canada;
import java.util.*;
import JavaAPI.*;
public class TestCanadaResPurchaseCCCustInfo
{
public static void main(String[] args)
{
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String store_id = "store1";
String api_token = "yesguy";
String data_key = "eLqsADfwqHDxIpJG9vLnELx01";
String amount = "1.00";
String cust_id = "customer1"; //if sent will be submitted, otherwise cust_id from profile will be used
String crypt_type = "1";
boolean status_check = false;
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
resPurchaseCC.setData(data_key);
resPurchaseCC.setOrderId(order_id);
resPurchaseCC.setCustId(cust_id);
resPurchaseCC.setAmount(amount);
resPurchaseCC.setCryptType(crypt_type);
//CustInfo Variables
CustInfo custInfo = new CustInfo();
custInfo.setEmail("nick@widget.com");
custInfo.setInstructions("Make it fast!");
Hashtable<String, String> b = new Hashtable<String, String>();
b.put("first_name", "Bob");
b.put("last_name", "Smith");
b.put("company_name", "Widget Company Inc.");
b.put("address", "111 Bolts Ave.");
b.put("city", "Toronto");
b.put("province", "Ontario");
b.put("postal_code", "M8T 1T8");
b.put("country", "Canada");
b.put("phone", "416-555-5555");
b.put("fax", "416-555-5555");
b.put("tax1", "123.45"); //federal tax
b.put("tax2", "12.34"); //prov tax
b.put("tax3", "15.45"); //luxury tax
b.put("shipping_cost", "456.23"); //shipping cost
custInfo.setBilling(b);
/* OR you can pass the individual args.
custInfo.setBilling(
"Bob", //first name
"Smith", //last name
"Widget Company Inc.", //company name
"111 Bolts Ave.", //address
"Toronto", //city
"Ontario", //province
"M8T 1T8", //postal code
"Canada", //country
"416-555-5555", //phone
"416-555-5555", //fax
"123.45", //federal tax
"12.34", //prov tax
"15.45", //luxury tax
"456.23" //shipping cost
);
*/
Hashtable<String, String> s = new Hashtable<String, String>();
s.put("first_name", "Bob");
s.put("last_name", "Smith");
s.put("company_name", "Widget Company Inc.");
s.put("address", "111 Bolts Ave.");
s.put("city", "Toronto");
s.put("province", "Ontario");
s.put("postal_code", "M8T 1T8");
s.put("country", "Canada");
s.put("phone", "416-555-5555");
s.put("fax", "416-555-5555");
s.put("tax1", "123.45"); //federal tax
s.put("tax2", "12.34"); //prov tax
s.put("tax3", "15.45"); //luxury tax
s.put("shipping_cost", "456.23"); //shipping cost
custInfo.setShipping(s);
/* OR you can pass the individual args.
custInfo.setShipping(
"Bob", //first name
"Smith", //last name
"Widget Company Inc.", //company name
"111 Bolts Ave.", //address
"Toronto", //city
"Ontario", //province
"M8T 1T8", //postal code
"Canada", //country
"416-555-5555", //phone
"416-555-5555", //fax
"123.45", //federal tax
"12.34", //prov tax
"15.45", //luxury tax
"456.23" //shipping cost
);
*/
Hashtable<String, String> i1 = new Hashtable<String, String>();
i1.put("name", "item1's name");
i1.put("quantity", "5");
i1.put("product_code", "item1's product code");
i1.put("extended_amount", "1.01");
custInfo.setItem(i1);
/* OR you can pass the individual args.
custInfo.setItem(
"item1's name", //name
"5", //quantity
"item1's product code", //product code
"1.01" //extended amount
);
*/
Hashtable<String, String> i2 = new Hashtable<String, String>();
i2.put("name", "item2's name");
i2.put("quantity", "7");
i2.put("product_code", "item2's product code");
i2.put("extended_amount", "5.01");
custInfo.setItem(i2);
resPurchaseCC.setCustInfo(custInfo);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(resPurchaseCC);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("DataKey = " + receipt.getDataKey());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Message = " + receipt.getMessage());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("ResSuccess = " + receipt.getResSuccess());
System.out.println("PaymentType = " + receipt.getPaymentType());
System.out.println("Cust ID = " + receipt.getResCustId());
System.out.println("Phone = " + receipt.getResPhone());
System.out.println("Email = " + receipt.getResEmail());
System.out.println("Note = " + receipt.getResNote());
System.out.println("Masked Pan = " + receipt.getResMaskedPan());
System.out.println("Exp Date = " + receipt.getResExpdate());
System.out.println("Crypt Type = " + receipt.getResCryptType());
System.out.println("Avs Street Number = " + receipt.getResAvsStreetNumber());
System.out.println("Avs Street Name = " + receipt.getResAvsStreetName());
System.out.println("Avs Zipcode = " + receipt.getResAvsZipcode());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase with Vault - Transaction Values
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(resPurchaseCC);
Purchase with Vault mandatory values
Purchase with Vault optional values
CustInfo object mandatory properties
Setting Billing & Shipping using Set Methods
The billing information and the shipping information for a given CustInfo object are written by using the customer.setBilling() and customer.setShipping() methods respectively:
customer.setBilling(first_name, last_name, company_name, address, city, province, postal_code, country, phone, fax, tax1, tax2, tax3, shipping_cost);
customer.setShipping(first_name, last_name, company_name, address, city, province, postal_code, country, phone, fax, tax1, tax2, tax3, shipping_cost);
Both of these methods have the same set of mandatory arguments.
Setting Billing & Shipping using Hash Tables
Writing billing or shipping information using hash tables is done as follows:
- Instantiate a CustInfo object.
- Instantiate a Hashtable object. (The sample code uses a different hash table for billing and shipping for clarity purposes. However, the skillful developer can re-use the same one.)
- Build the hashtable using put methods with the hash table keys in the table below.
- Call the CustInfo object's setBilling()/setShipping() method to pass the hashtable information to the CustInfo object
- Call the transaction object's setCustInfo() method to write the CustInfo object (with the billing/shipping information to the transaction object.
Billing & Shipping mandatory values
Setting Items using Set Methods
All the item information in the table below is written to the CustInfo object in one instruction for a given item. Multiples items may be set. Such as:
customer.setItem(item_description, item_quantity, item_product_code, item_extended_amount);
Setting Items using Hash Tables
Writing item information using hash tables is done as follows:
- Instantiate a CustInfo object.
- Instantiate a Hashtable object. (The sample code uses a different hash table for each item for clarity purposes. However, the skillful developer can re-use the same one.)
- Build the hashtable using put methods with the hash table keys in the table below.
- Call the CustInfo object's setItem() method to pass the hashtable information to the CustInfo object
- Call the transaction object's setCustInfo() method to write the CustInfo object (with the item information to the transaction object.
Item mandatory values
Vault Response Fields
Purchase with Vault and Recurring Billing
This transaction uses the data key to identify a previously registered credit card profile. The details saved within the profile are then submitted to perform a Purchase transaction.
The data key may be a temporary one generated using Hosted Tokenization or it may be a permanent one from the Vault.
The Vault feature allows merchants to create customer profiles, edit those profiles, and use them to process transactions without having to enter financial information each time.
The Vault is a complement to the recurring payment module. It securely stores customer account information on Moneris secure servers. This allows merchants to bill customers for routine products or services when an invoice is due.
This transaction allows the merchant to process a Purchase transaction using a data key to reference the card number already on file. In addition, it also registers a new recurring billing profile where going forward Moneris will automatically process the recurring transaction and will bill customers on your behalf based on the billing cycle information you provide.
In addition to instantiating a transaction object and a connection object (as you would for a normal transaction), you must instantiate a Recur object. This object has a number of mandatory properties that must be set.
Any transaction that supports Recurring Billing has a setRecur method. This is used to write the Recurring Billing information to the transaction object before writing the transaction object to the connection object.
Things to consider:
- To avoid shifting, do not set the start_date after the 28th if the recur_unit is month. To set the billing date for the last day of the month, set recur_unit to eom.
package Canada;
import JavaAPI.*;
public class TestCanadaResPurchaseCCRecur
{
public static void main(String[] args)
{
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String store_id = "store1";
String api_token = "yesguy";
String data_key = "eLqsADfwqHDxIpJG9vLnELx01";
String amount = "1.00";
String cust_id = "customer1"; //if sent will be submitted, otherwise cust_id from profile will be used
String crypt_type = "2";
boolean status_check = false;
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
resPurchaseCC.setData(data_key);
resPurchaseCC.setOrderId(order_id);
resPurchaseCC.setCustId(cust_id);
resPurchaseCC.setAmount(amount);
resPurchaseCC.setCryptType(crypt_type);
/************************* Recur Variables **********************************/
String recur_unit = "month";
String start_now = "false";
String start_date = "2019/12/01";
String num_recurs = "12";
String period = "1";
String recur_amount = "30.00";
/************************* Recur Object Option1 ******************************/
Recur recurring_cycle = new Recur(recur_unit, start_now, start_date,
num_recurs, period, recur_amount);
resPurchaseCC.setRecur(recurring_cycle);
//Mandatory - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("R");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
resPurchaseCC.setCofInfo(cof);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(resPurchaseCC);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("DataKey = " + receipt.getDataKey());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Message = " + receipt.getMessage());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("AVSResponse = " + receipt.getAvsResultCode());
System.out.println("CVDResponse = " + receipt.getCvdResultCode());
System.out.println("RecurSuccess = " + receipt.getRecurSuccess());
System.out.println("ResSuccess = " + receipt.getResSuccess());
System.out.println("PaymentType = " + receipt.getPaymentType());
System.out.println("Cust ID = " + receipt.getResCustId());
System.out.println("Phone = " + receipt.getResPhone());
System.out.println("Email = " + receipt.getResEmail());
System.out.println("Note = " + receipt.getResNote());
System.out.println("Masked Pan = " + receipt.getResMaskedPan());
System.out.println("Exp Date = " + receipt.getResExpdate());
System.out.println("Crypt Type = " + receipt.getResCryptType());
System.out.println("Avs Street Number = " + receipt.getResAvsStreetNumber());
System.out.println("Avs Street Name = " + receipt.getResAvsStreetName());
System.out.println("Avs Zipcode = " + receipt.getResAvsZipcode());
System.out.println("IssuerId = " + receipt.getIssuerId());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase with Vault - Transaction Values
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(resPurchaseCC);
Purchase with Vault mandatory values
Purchase with Vault optional values
Recurring object mandatory values
Recurring Billing Response Fields
Vault Response Fields
Purchase with Vault and CVD & AVS
This transaction uses the data key to identify a previously registered credit card profile. The details saved within the profile are then submitted to perform a Purchase transaction.
The data key may be a temporary one generated using Hosted Tokenization or it may be a permanent one from the Vault.
The Card Validation Digits (CVD) value refers to the numbers appearing on the back of the credit card rather than the numbers imprinted on the front. It is an optional fraud prevention tool that enables merchants to verify data provided by the cardholder at transaction time. This data is submitted along with the transaction to the issuing bank, which provides a response indicating whether the data is a match.
The response that is received from CVD verification is intended to provide added security and fraud prevention, but the response itself does not affect the completion of a transaction. Upon receiving a response, the choice whether to proceed with a transaction is left entirely to the merchant. The response is not a strict guideline of which transaction will approve or decline.
Address Verification Service (AVS) is an optional fraud-prevention tool offered by issuing banks whereby a cardholder's address is submitted as part of the transaction authorization. The AVS address is then compared to the address kept on file at the issuing bank. AVS checks whether the street number, street name and zip/postal code match. The issuing bank returns an AVS result code indicating whether the data was matched successfully. Regardless of the AVS result code returned, the credit card is authorized or declined by the issuing bank.
The response that is received from AVS verification is intended to provide added security and fraud prevention, but the response itself does not affect the completion of a transaction. Upon receiving a response, the choice to proceed with a transaction is left entirely to the merchant. The responses is not a strict guideline of whether a transaction will be approved or declined.
Things to consider:
- CVD is only supported by Visa, MasterCard, Discover, JCB, American Express and UnionPay.
- AVS is only supported by Visa, MasterCard, Discover and American Express.
- When testing CVD or AVS, you must only use the Visa test card numbers 4242424242424242 or 4005554444444403, and the amounts described in the Simulator eFraud Response Codes Table.
- For a full list of possible AVS & CVD result codes refer to the CVD AVS Result Code table.
Security:The CVD value must only be passed to the payment gateway. Under no circumstances may it be stored for subsequent uses or displayed as part of the receipt information.
Note:Please be advised that CVD results will
NOT be returned in the response for UnionPay.
package Canada;
import JavaAPI.*;
public class TestCanadaResPurchaseCCEfraud
{
public static void main(String[] args)
{
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String store_id = "store1";
String api_token = "yesguy";
String data_key = "eLqsADfwqHDxIpJG9vLnELx01";
String amount = "1.00";
String cust_id = "customer1"; //if sent will be submitted, otherwise cust_id from profile will be used
String crypt_type = "1";
boolean status_check = false;
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
resPurchaseCC.setData(data_key);
resPurchaseCC.setOrderId(order_id);
resPurchaseCC.setCustId(cust_id);
resPurchaseCC.setAmount(amount);
resPurchaseCC.setCryptType(crypt_type);
/*************** Address Verification Service **********************/
AvsInfo avsCheck = new AvsInfo();
avsCheck.setAvsStreetNumber("212");
avsCheck.setAvsStreetName("Payton Street");
avsCheck.setAvsZipCode("M1M1M1");
avsCheck.setAvsEmail("test@host.com");
avsCheck.setAvsHostname("hostname");
avsCheck.setAvsBrowser("Mozilla");
avsCheck.setAvsShiptoCountry("CAN");
avsCheck.setAvsShipMethod("G");
avsCheck.setAvsMerchProdSku("123456");
avsCheck.setAvsCustIp("192.168.0.1");
avsCheck.setAvsCustPhone("5556667777");
resPurchaseCC.setAvsInfo(avsCheck);
/****************** Card Validation Digits *************************/
CvdInfo cvdCheck = new CvdInfo();
cvdCheck.setCvdIndicator("1");
cvdCheck.setCvdValue("099");
resPurchaseCC.setCvdInfo(cvdCheck);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(resPurchaseCC);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("DataKey = " + receipt.getDataKey());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Message = " + receipt.getMessage());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("AVSResponse = " + receipt.getAvsResultCode());
System.out.println("CVDResponse = " + receipt.getCvdResultCode());
System.out.println("ITDResponse = " + receipt.getITDResponse());
System.out.println("ResSuccess = " + receipt.getResSuccess());
System.out.println("PaymentType = " + receipt.getPaymentType());
//ResolveData
System.out.println("Cust ID = " + receipt.getResCustId());
System.out.println("Phone = " + receipt.getResPhone());
System.out.println("Email = " + receipt.getResEmail());
System.out.println("Note = " + receipt.getResNote());
System.out.println("Masked Pan = " + receipt.getResMaskedPan());
System.out.println("Exp Date = " + receipt.getResExpdate());
System.out.println("Crypt Type = " + receipt.getResCryptType());
System.out.println("Avs Street Number = " + receipt.getResAvsStreetNumber());
System.out.println("Avs Street Name = " + receipt.getResAvsStreetName());
System.out.println("Avs Zipcode = " + receipt.getResAvsZipcode());
}
catch (Exception e)
{
e.printStackTrace();
}
}
} // end TestResPurchaseCC-Efraud
Purchase with Vault - Transaction Values
ResPurchaseCC resPurchaseCC = new ResPurchaseCC();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(resPurchaseCC);
Purchase with Vault mandatory values
Purchase with Vault optional values
CvdInfo object mandatory values
AvsInfo object mandatory values
CVD & AVS Response Fields
Vault Response Fields
Purchase with Vault and 3-D Secure
This transaction uses the data key to identify a previously registered credit card profile. The details saved within the profile are then submitted to perform a Purchase transaction.
The Purchase with 3-D Secure transaction follows a 3-D Secure MPI authentication. After receiving confirmation from the MPI ACS transaction, this Purchase verifies funds on the customer’s card, removes the funds and prepares them for deposit into the merchant’s account.
To perform the 3-D Secure authentication, the Moneris MPI or any 3rd party MPI may be used.
In addition to 3-D Secure transactions, this transaction can also be used to process Apple Pay and Google Pay™ transactions. This transaction is applicable only if choosing to integrate directly to Apple Wallet or Google Wallet (if not using the Moneris Apple Pay or Google Pay™ SDKs).
Refer to Apple or Google developer portals for details on integrating directly to their wallets to retrieve the payload data.
NOTE: Moneris strongly discourages the use of frames as part of a 3-D Secure implementation, and cannot guarantee their reliability when processing transactions in the production environment.
package Canada;
import JavaAPI.*;
public class TestCanadaResCavvPurchaseCC
{
public static void main(String[] args)
{
String store_id = "store1";
String api_token = "yesguy";
String data_key = "4INQR1A8ocxD0oafSz50LADXy";
java.util.Date createDate = new java.util.Date();
String order_id = "Test"+createDate.getTime();
String amount = "1.00";
String cust_id = "customer1"; //if sent will be submitted, otherwise cust_id from profile will be used
String cavv = "AAABBJg0VhI0VniQEjRWAAAAAAA";
String exp_date = "1901";
boolean status_check = false;
ResCavvPurchaseCC resCavvPurchaseCC = new ResCavvPurchaseCC();
resCavvPurchaseCC.setOrderId(order_id);
resCavvPurchaseCC.setData(data_key);
resCavvPurchaseCC.setCustId(cust_id);
resCavvPurchaseCC.setAmount(amount);
resCavvPurchaseCC.setCavv(cavv);
resCavvPurchaseCC.setExpDate(exp_date);
//Mandatory - Credential on File details
CofInfo cof = new CofInfo();
cof.setPaymentIndicator("U");
cof.setPaymentInformation("2");
cof.setIssuerId("139X3130ASCXAS9");
resCavvPurchaseCC.setCofInfo(cof);
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setProcCountryCode(processing_country_code);
mpgReq.setTestMode(true); //false or comment out this line for production transactions
mpgReq.setStoreId(store_id);
mpgReq.setApiToken(api_token);
mpgReq.setTransaction(resCavvPurchaseCC);
mpgReq.setStatusCheck(status_check);
mpgReq.send();
try
{
Receipt receipt = mpgReq.getReceipt();
System.out.println("DataKey = " + receipt.getDataKey());
System.out.println("ReceiptId = " + receipt.getReceiptId());
System.out.println("ReferenceNum = " + receipt.getReferenceNum());
System.out.println("ResponseCode = " + receipt.getResponseCode());
System.out.println("AuthCode = " + receipt.getAuthCode());
System.out.println("Message = " + receipt.getMessage());
System.out.println("TransDate = " + receipt.getTransDate());
System.out.println("TransTime = " + receipt.getTransTime());
System.out.println("TransType = " + receipt.getTransType());
System.out.println("Complete = " + receipt.getComplete());
System.out.println("TransAmount = " + receipt.getTransAmount());
System.out.println("CardType = " + receipt.getCardType());
System.out.println("TxnNumber = " + receipt.getTxnNumber());
System.out.println("TimedOut = " + receipt.getTimedOut());
System.out.println("ResSuccess = " + receipt.getResSuccess());
System.out.println("PaymentType = " + receipt.getPaymentType());
System.out.println("CavvResultCode = " + receipt.getCavvResultCode());
System.out.println("IssuerId = " + receipt.getIssuerId());
//ResolveData
System.out.println("Cust ID = " + receipt.getResCustId());
System.out.println("Phone = " + receipt.getResPhone());
System.out.println("Email = " + receipt.getResEmail());
System.out.println("Note = " + receipt.getResNote());
System.out.println("Masked Pan = " + receipt.getResMaskedPan());
System.out.println("Exp Date = " + receipt.getResExpdate());
System.out.println("Crypt Type = " + receipt.getResCryptType());
System.out.println("Avs Street Number = " + receipt.getResAvsStreetNumber());
System.out.println("Avs Street Name = " + receipt.getResAvsStreetName());
System.out.println("Avs Zipcode = " + receipt.getResAvsZipcode());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Purchase with Vault and 3-D Secure - Transaction Values
ResCavvPurchaseCC resCavvPurchaseCC = new ResCavvPurchaseCC();
HttpsPostRequest mpgReq = new HttpsPostRequest();
mpgReq.setTransaction(resCavvPurchaseCC);
Mandatory Values
Optional Values
3-D Secure Response Fields
Vault Response Fields